<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://xmlns.jcp.org/jsf/html"
	xmlns:f="http://xmlns.jcp.org/jsf/core" xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
	xmlns:pt="http://xmlns.jcp.org/jsf/passthrough" xmlns:cc="http://xmlns.jcp.org/jsf/composite">

	<cc:interface>
		<cc:attribute name="workitem"></cc:attribute>
		<cc:attribute name="styleClass"></cc:attribute>
		<cc:attribute name="showattachments" default="false" type="java.lang.Boolean"></cc:attribute>
		<cc:attribute name="labelButton" default="File Upload"></cc:attribute>
		<cc:attribute name="labelHelp" default="drop files here..."></cc:attribute>
		<cc:attribute name="context_url"></cc:attribute>
	</cc:interface>

	<cc:implementation>
		<h:panelGroup layout="block" styleClass="imixsfileupload #{cc.attrs.styleClass}">
			<!-- #{fileUploadController.setWorkitem(cc.attrs.workitem)} -->
			<h:inputFile id="imixsfileInput" class="imixsfileuploadinput" value="#{fileUploadController.files}"
				pt:multiple="true" onchange="imixsFileUploadRefresh()" />
			<h:outputLabel for="imixsfileInput">#{cc.attrs.labelButton}</h:outputLabel><span
				class="drop-area">#{cc.attrs.labelHelp}</span>
			<div class="imixsfileupload-table"></div>

			<!-- show  attachments from workitem -->
			<ui:fragment rendered="#{cc.attrs.showattachments}">
				<h:panelGroup layout="block" styleClass="imixsfileupload-table" id="persistendFileListID">
					<!-- attached files -->
					<h:dataTable value="#{cc.attrs.workitem.fileData}" var="fileData"
						styleClass="imixsFileUpload_uploadlist" >
							<h:column>
								<f:facet name="header">File Name</f:facet>
								<h:outputText escape="false" value="&lt;a class='imixsFileUpload_file' target='_blank' href='" />
								<h:outputText escape="false"
									value="#{cc.attrs.context_url}/file/#{fileData.name}" />
								<h:outputText escape="false" value="'&gt;#{fileData.name}&lt;/a&gt;" />
							</h:column>
							<h:column>
								<f:facet name="header">Size</f:facet>
								#{fileUploadController.getFileSize(fileData.name)}
							</h:column>
							<h:column>
								<f:facet name="header">User Info</f:facet>
								#{fileUploadController.getUserInfo(fileData.name)}
							</h:column>
							<h:column><f:facet name="header">Type</f:facet>
								#{fileData.contentType}
							</h:column>
							<!--  delete stored file  -->
							<h:column>
								<h:commandLink value="🗙" styleClass="remove-link"
									actionListener="#{fileUploadController.removeAttachedFile(fileData.name)}">
									<f:ajax render=":#{component.parent.parent.parent.clientId}"/>
									<f:param name="cid" value="#{fileUploadController.getCID()}" />
								</h:commandLink>
							</h:column>
					</h:dataTable>
				</h:panelGroup>
			</ui:fragment>
		</h:panelGroup>

	</cc:implementation>



</ui:composition>